using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class vItemSaleMap : EntityTypeConfiguration<vItemSale>
    {
        public vItemSaleMap()
        {
            // Primary Key
            this.HasKey(t => new { t.Item, t.Date, t.Doctype });

            // Properties
            this.Property(t => t.Item)
                .IsRequired()
                .HasMaxLength(10);

            this.Property(t => t.Doctype)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            // Table & Column Mappings
            this.ToTable("vItemSales");
            this.Property(t => t.Item).HasColumnName("Item");
            this.Property(t => t.Qty).HasColumnName("Qty");
            this.Property(t => t.CostAMount).HasColumnName("CostAMount");
            this.Property(t => t.totalAMount).HasColumnName("totalAMount");
            this.Property(t => t.Date).HasColumnName("Date");
            this.Property(t => t.Doctype).HasColumnName("Doctype");
        }
    }
}
